home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Developer Helper 1: Phil & Dave's Excellent CD
/
Excellent CD HFS.raw
/
Moof
/
Goodies
/
HyperCard Goodies
/
HyperCard Dev. ToolKit
/
Serial & MacinTalk XCMDs
/
XCmdForC.p
< prev
next >
Wrap
Text File
|
1987-07-15
|
4KB
|
127 lines
{$R-}
{$D+}
(*
XCmdForC.p Package of routines in Pascal, but for use from C.
All standard HyperCard callback routines.
Copyright Apple Computer, Inc. (c) 1987.
To compile and link this file using Macintosh Programmer's Workshop
(HyperXCmd.p and XCmdGlue.inc must be accessible):
pascal XCmdForC.p
See Flash.C for an example of how to use this module. Your C file
must include HyperXCmd.h
*)
UNIT XCmdForC;
INTERFACE
USES MemTypes, QuickDraw, HyperXCmd;
TYPE Str31 = String[31];
{ Str19 = String[19]; }
{ You MUST call SetParamPtr first to tell the package about the parameter }
{ block that HyperCard supplied. Only then can you call the other routines. }
PROCEDURE SetParamPtr(myParamPtr: XCmdPtr);
FUNCTION EvalExpr(expr: Str255): Handle;
{ Given a HyperTalk expression in ASCII, return a handle to a zero-terminated
string with the answer. }
PROCEDURE SendCardMessage(msg: Str255);
{ Send a HyperCard message (command) to the current card. }
FUNCTION GetGlobal(globName: Str255): Handle;
PROCEDURE SetGlobal(globName: Str255; globValue: Handle);
FUNCTION GetFieldByName(cardFieldFlag: BOOLEAN; fieldName: Str255): Handle;
FUNCTION GetFieldByNum(cardFieldFlag: BOOLEAN; fieldNum: INTEGER): Handle;
FUNCTION GetFieldByID(cardFieldFlag: BOOLEAN; fieldID: INTEGER): Handle;
PROCEDURE SetFieldByName(cardFieldFlag: BOOLEAN; fieldName: Str255; fieldVal: Handle);
PROCEDURE SetFieldByNum(cardFieldFlag: BOOLEAN; fieldNum: INTEGER; fieldVal: Handle);
PROCEDURE SetFieldByID(cardFieldFlag: BOOLEAN; fieldID: INTEGER; fieldVal: Handle);
PROCEDURE ZeroToPas(zeroStr: Ptr; VAR pasStr: Str255);
{ Convert a zero terminated string to a Pascal string. You create the
Pascal string and pass it in as a VAR parameter. Useful for converting
the arguments of any XCMD to Pascal strings. (See PasToZero below). }
FUNCTION StrToNum(str: Str31): LongInt;
{ Convert ASCII of a decimal number to the number. }
FUNCTION StrToLong(str: Str31): LongInt;
{ Convert ASCII of a decimal number to the number. Negative numbers not
accepted. }
FUNCTION StrToExt(str: Str31): Extended;
FUNCTION StrToBool(str: Str31): BOOLEAN;
{ Convert ASCII "true" and "false" to Pascal booleans. }
FUNCTION StringLength(strPtr: Ptr): LongInt;
FUNCTION StringEqual(str1,str2: Str255): BOOLEAN;
FUNCTION StringMatch(pattern: Str255; target: Ptr): Ptr;
PROCEDURE ReturnToPas(zeroStr: Ptr; VAR pasStr: Str255);
PROCEDURE ScanToReturn(VAR scanPtr: Ptr);
PROCEDURE ScanToZero(VAR scanPtr: Ptr);
PROCEDURE ZeroBytes(dstPtr: Ptr; longCount: LongInt);
FUNCTION LongToStr(posNum: LongInt): Str31;
{ Convert a longInt to decimal ASCII. }
FUNCTION NumToStr(num: LongInt): Str31;
{ Convert a longInt to decimal ASCII, using a minus sign for negative
numbers. }
FUNCTION NumToHex(num: LongInt; nDigits: INTEGER): Str31;
{ Convert a longInt to hexadecimal ASCII, using a minus sign for
negative numbers. }
FUNCTION ExtToStr(num: Extended): Str31;
FUNCTION BoolToStr(bool: BOOLEAN): Str31;
{ Convert a boolean to ASCII "true" or "false". }
FUNCTION PasToZero(str: Str255): Handle;
{ Convert a pascal string to a zero-terminated string. You'll need to do
this for any result or argument you return to HyperTalk. }
IMPLEMENTATION
VAR paramPtr: XCmdPtr; {global set by SetParamPtr}
PROCEDURE SetParamPtr(myParamPtr: XCmdPtr);
{ You must call this to tell the package about the parameter block }
{ that HyperCard supplied. Only then can you call the other routines. }
BEGIN
paramPtr := myParamPtr;
END;
{$I XCmdGlue.inc }
END.